{extend name="public/help" /}
{block name="oneMenuName"}{$crumbs['oneMenuName']}{/block}
{block name="twoMenuName"}{$crumbs['twoMenuName']}{/block}
{block name="body"}
<div class="main-content">
    <form enctype="multipart/form-data" method="post" id="topform">
        <input type="hidden" value="{$id}" name="id">
        <div class="row">
            <div class="col-lg-6">
                <div class="card alert">
                    <div class="card-header">
                        <h4 >修改订单</h4>
                    </div>
                    <div class="card-body">
                        <div class="basic-form">
                            <div class="form-group">
                                <label>订单编号</label>
                                <input type="text" id="name" class="form-control" value="{$data['order_code']}" disabled="disabled">
                            </div>
                            <div class="form-group">
                                <label>用户名</label>
                                <input type="text" id="user_name" class="form-control" value="{$data['user_name']}" disabled="disabled">
                            </div>

                            <div class="form-group">
                                <label>收货地址</label>
                                <input type="text" id="addr" class="form-control" value="{$data['addr']}" disabled="disabled">
                            </div>

                            <div class="form-group">
                                <label>快递公司</label>
                                <input type="text" name="express_name" id="express_name" class="form-control" value="{$data['express_name']}">
                            </div>
                            <div class="form-group">
                                <label>快递单号</label>
                                <input type="text" name="express_code" id="express_code" class="form-control" value="{$data['express_code']}">
                            </div>
                            <!--<div class="form-group">-->
                            <!--    <label>商家图片</label>-->
                            <!--    <input type="text" name="img" id="img" class="form-control" value="" placeholder="url (七牛云的外链)">-->
                            <!--</div>-->
                            <button type="button" id="submit" class="btn btn-success m-b-10 m-l-5">确定</button>
                        </div>
                    </div>
                </div>
            </div><!-- /# column -->
        </div><!-- /# row -->
        <!--</form>-->
</div><!-- /# container-fluid -->

{/block}
{block name="js"}
<script>
    $('#submit').click(function(){
        var express_name = $('#express_name').val();
        var express_code = $('#express_code').val();

        if(!express_name){ error('快递公司有误'); return; }
        if(!express_code){ error('快递单号有误'); return; }

        var formData = new FormData($( "#topform" )[0]);

        var id = $('input[name="id"]').val();
        if(id){
            var url = "{:url('/admin/editSaasOrder')}";
        }

        $.ajax({
            type:'post',
            url:url,
            data:formData,
            cache: false,
            contentType: false,
            processData: false,
            success:function(res){
                if(res.code){
                    redirect_success(res.msg, res.url);
                }else{
                    error(res.msg);
                }
            }
        });
    });
</script>
{/block}
